package com.itheima.convert;

import com.itheima.entity.Organization;
import com.itheima.entity.User;
import com.itheima.vo.organization.OrganizationBriefVo;
import com.itheima.vo.organization.OrganizationDetailVo;
import com.itheima.vo.organization.OrganizationExcelVo;
import com.itheima.vo.organization.OrganizationVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * <h1>组织转换接口</h1>
 *
 * @author <a href="515857087@qq.com">叶世铭</a>
 * @since 2022/12/3
 */
@Mapper(componentModel = "spring")
public interface OrganizationConvert {

    /**
     * Organization -> OrganizationVo*
     * @param organization 组织实体
     * @return 组织的多级列表映射
     */
    @Mapping(target = "userList", ignore = true)
    @Mapping(target = "children", ignore = true)
    @Mapping(target = "label", source = "name")
    OrganizationVo organizationToOrganizationVo(Organization organization);

    /**
     * Organization -> OrganizationDetailVo
     * @param organization 组织实体
     * @return 组织详情vo
     */
    @Mappings({
            @Mapping(target = "organizationId", source = "id"),
            @Mapping(target = "organizationName", source = "name")
    })
    OrganizationDetailVo toOrganizationDetailVo(Organization organization);

    /**
     * List<Organization> -> List<OrganizationBriefVo>
     * @param list 组织实体
     * @return 组织简略信息vo
     */
    List<OrganizationBriefVo> toOrganizationBriefVo(List<Organization> list);

    /**
     * List<User> -> List<OrganizationExcelVo>
     * @param userList 用户信息集合
     * @return 组织导出vo
     */
    List<OrganizationExcelVo> toOrganizationExcelVo(List<User> userList);

    /**
     * User -> OrganizationExcelVo
     * @param user 用户实体
     * @return 组织导出vo
     */
    @Mappings({
            @Mapping(target = "userId",source = "id"),
            @Mapping(target = "userName",source = "name")
    })
    OrganizationExcelVo toOrganizationExcelVo(User user);
}
